def candiv(n, a, b):
    p = 2
    while p * p <= a or a > 1:
        if p * p > a:
            p = a
        if a % p == 0:
            count_ab = 0
            while a % p == 0:
                count_ab += 1
                a //= p
            count_ab *= b
            count_fac = 0
            d = p
            while n >= d:
                count_fac += n // d
                d *= p
            if count_fac < count_ab:
                return False
        p += 1
    return True

for _ in range(int(input())):
    n = int(input())
    a = int(input())
    b = int(input())
    if candiv(n, a, b):
        print('Yes')
    else:
        print('No')
